package org.restorator.dao.implement.engin;

import org.restorator.dao.base.ItemDao;
import org.restorator.dao.base.UserDao;
import org.restorator.dao.jdbc.Enricher;
import org.restorator.entity.Order;
import org.restorator.exception.DataStoreException;
import org.restorator.utill.GeneralUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.sql.ResultSet;

/**
 * @author Snisar Bogdan.
 */
public class OrderEnricher implements Enricher<Order> {
    private static Logger logger = LoggerFactory.getLogger(GeneralUtil.getClassName());


    private final ItemDao itemDao;

    public OrderEnricher(ItemDao itemDao) {
        this.itemDao = itemDao;
    }

    @Override
    public void enrich(Order enrichable) throws DataStoreException {
        logger.trace("Enrichable object {}", enrichable);
        if(enrichable != null) {
            enrichable.setItems(itemDao.getItemsByOrderId(enrichable.getOrderId()));
        }
//        enrichable.setUser(userDao.getUserByOrderId(enrichable.getOrderId()));
    }

    @Override
    public void insert(Order obj) {
        //To change body of implemented methods use File | Settings | File Templates.
    }

    @Override
    public void update(Order obj) {
     /*NOPE
     * We don't want to update Items or user ref by Order class.
     */
    }

    @Override
    public void delete(Order obj) {
        //To change body of implemented methods use File | Settings | File Templates.
    }

}
